package net.huashitong.synthetical.showView.web;

import com.alibaba.fastjson.JSONObject;
import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.core.web.model.Message;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

import static net.huashitong.synthetical.showView.util.HttpsUtils.doGet;
import static net.huashitong.synthetical.showView.util.HttpsUtils.doPost;

@Controller
@RequestMapping(value = "/urlApp")
public class UrlController extends JsonBaseController {
    @Override
    protected String getView(String s) {
        return null;
    }

    @ResponseBody
    @RequestMapping(value = "/getdemo", method = RequestMethod.GET)
    public Message getdemo(){
        String url = "http://211.103.185.201:20123/pub/app_2/dataquery?db=appfsjnd&zb=A010101&sj=2016&tt=SGB0103&reg=GX350200";
        JSONObject jsonObject = doGet(url);
        Integer returncode = jsonObject.getInteger("returncode");
        return coverMessage("200","成功",returncode);
    }


    @ResponseBody
    @RequestMapping(value = "/getdemo1", method = RequestMethod.GET)
    public Message getdemo1(){
        String url = "https://www.fzzhengxinyun.com/chart/getDetailTimeByProjectId?projectId=20180312100000000352";
        JSONObject jsonObject = doGet(url);
        Integer returncode = jsonObject.getInteger("returncode");
        return coverMessage("200","成功",returncode);
    }



    @ResponseBody
    @RequestMapping(value = "/postdemo", method = RequestMethod.GET)
    public Message postdemo(){
        String url = "http://211.149.245.16:8889/app/aiReport/dealReport";
        Map<String,String> map = new HashMap<>();
        Object json = new Object();
        map.put("date","201809");
        JSONObject jsonObject = doPost(url,json);
        Integer returncode = jsonObject.getInteger("returncode");
        return coverMessage("200","成功",returncode);
    }

}
